package com.jaychen.eureka.client.domain;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 实列
 *
 * @Author Jay Chen
 * @Date 2020/10/22 20:05
 */
public class InstanceInfo {

    private static final Logger logger = LoggerFactory.getLogger(InstanceInfo.class);

    private String appName;
    private String instanceId;
    private String port;
    private String address;
    private InstanceStatus instanceStatus = InstanceStatus.UP;

    public enum InstanceStatus {
        UP,
        DOWN,
        UNKNOWN;

        public static InstanceStatus toEnum(String s) {
            if (s != null) {
                try {
                    return InstanceStatus.valueOf(s.toUpperCase());
                } catch (IllegalArgumentException e) {
                    // ignore and fall through to unknown
                    logger.debug("illegal argument supplied to InstanceStatus.valueOf: {}, defaulting to {}", s, UNKNOWN);
                }
            }
            return UNKNOWN;
        }
    }


    public String getAppName() {
        return appName;
    }

    public void setAppName(String appName) {
        this.appName = appName;
    }

    public String getInstanceId() {
        return instanceId;
    }

    public void setInstanceId(String instanceId) {
        this.instanceId = instanceId;
    }

    public InstanceStatus getInstanceStatus() {
        return instanceStatus;
    }

    public void setInstanceStatus(InstanceStatus instanceStatus) {
        this.instanceStatus = instanceStatus;
    }

    public static Logger getLogger() {
        return logger;
    }

    public String getPort() {
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }
}
